#pragma once

#include "Pin.h"


namespace uml {

const bool Pin::isControl_default_ = false;
Pin::Pin(const QString& umlType)
    : ObjectNode(umlType) {}

void Pin::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    MultiplicityElement::fromJson(json, errorList);
    ObjectNode::fromJson(json, errorList);
    isControl_ = json.value("isControl").toBool(isControl_default_);
}

void Pin::toJson(QJsonObject& json) {
    MultiplicityElement::toJson(json);
    ObjectNode::toJson(json);
    if (isControl_ != isControl_default_) {
        json.insert("isControl", isControl_);
    }
}

/// <summary>
/// isControl getter
/// Indicates whether the Pin provides data to the Action or just controls how the
/// Action executes.
/// </summary>
bool Pin::isControl() const {
    return isControl_;
}

/// <summary>
/// isControl setter
/// Indicates whether the Pin provides data to the Action or just controls how the
/// Action executes.
/// </summary>
void Pin::setIsControl(bool value) {
    isControl_ = value;
}

} // namespace uml
